//
// Created by lmy on 2024/11/18.
//

#include "initializer.h"
#include <iostream>
#include <initializer_list>
#include <vector>

double sum(std::initializer_list<double> il) {
    double total = 0;
    for (auto it = il.begin(); it != il.end(); it++)
        total = total + *it;
    return total;
}

int main() {
// double total = sum( 3.14, 5.20, 8 ); // 错误，如果没有⼤大括号，这是三个参数。
    double total = sum({3.14, 5.20, 8}); // 正确，有⼤大括号，这是⼀一个参数。
    std::cout << "total=" << total << std::endl;

    std::vector<int> v2{3,5,8};
}